/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * WizardView.java
 *
 * Created on 27/02/2011, 16:22:31
 */
package systole.view.wizard;

import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

/**
 *
 * @author jmj
 */
public class WizardView extends javax.swing.JDialog implements WindowListener {

    private WizardImplement wizardImpl;

    /** Creates new form WizardView */
    public WizardView(java.awt.Frame parent, WizardImplement wizardImpl) {
        super(parent, true);
        initComponents();
        this.wizardImpl = wizardImpl;
        this.addWindowListener(this);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPnlSteps = new javax.swing.JPanel();
        jPnlCenter = new javax.swing.JPanel();
        jPnlPages = new javax.swing.JPanel();
        jPnlBottom = new javax.swing.JPanel();
        jBtnBack = new javax.swing.JButton();
        jBtnNext = new javax.swing.JButton();
        jBtnFinish = new javax.swing.JButton();
        jBtnCancel = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setModal(true);
        setName("Form"); // NOI18N
        setResizable(false);

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(systole.view.SystoleApp.class).getContext().getResourceMap(WizardView.class);
        jPnlSteps.setBorder(new javax.swing.border.LineBorder(resourceMap.getColor("jPnlSteps.border.lineColor"), 1, true)); // NOI18N
        jPnlSteps.setName("jPnlSteps"); // NOI18N
        jPnlSteps.setPreferredSize(new java.awt.Dimension(160, 300));
        jPnlSteps.setLayout(new java.awt.BorderLayout());
        getContentPane().add(jPnlSteps, java.awt.BorderLayout.WEST);

        jPnlCenter.setName("jPnlCenter"); // NOI18N
        jPnlCenter.setPreferredSize(new java.awt.Dimension(450, 350));
        jPnlCenter.setLayout(new java.awt.BorderLayout());

        jPnlPages.setName("jPnlPages"); // NOI18N
        jPnlPages.setLayout(new java.awt.CardLayout());
        jPnlCenter.add(jPnlPages, java.awt.BorderLayout.CENTER);

        jPnlBottom.setBorder(javax.swing.BorderFactory.createLineBorder(resourceMap.getColor("jPnlBottom.border.lineColor"))); // NOI18N
        jPnlBottom.setName("jPnlBottom"); // NOI18N
        jPnlBottom.setPreferredSize(new java.awt.Dimension(450, 50));
        jPnlBottom.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT, 5, 15));

        jBtnBack.setText(resourceMap.getString("jBtnBack.text")); // NOI18N
        jBtnBack.setName("jBtnBack"); // NOI18N
        jBtnBack.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnBackActionPerformed(evt);
            }
        });
        jPnlBottom.add(jBtnBack);

        jBtnNext.setText(resourceMap.getString("jBtnNext.text")); // NOI18N
        jBtnNext.setName("jBtnNext"); // NOI18N
        jBtnNext.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnNextActionPerformed(evt);
            }
        });
        jPnlBottom.add(jBtnNext);

        jBtnFinish.setText(resourceMap.getString("jBtnFinish.text")); // NOI18N
        jBtnFinish.setName("jBtnFinish"); // NOI18N
        jBtnFinish.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnFinishActionPerformed(evt);
            }
        });
        jPnlBottom.add(jBtnFinish);

        jBtnCancel.setText(resourceMap.getString("jBtnCancel.text")); // NOI18N
        jBtnCancel.setName("jBtnCancel"); // NOI18N
        jBtnCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnCancelActionPerformed(evt);
            }
        });
        jPnlBottom.add(jBtnCancel);

        jPnlCenter.add(jPnlBottom, java.awt.BorderLayout.PAGE_END);

        getContentPane().add(jPnlCenter, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jBtnBackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnBackActionPerformed
        this.wizardImpl.previousPage();
    }//GEN-LAST:event_jBtnBackActionPerformed

    private void jBtnNextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnNextActionPerformed
         this.wizardImpl.nextPage();
    }//GEN-LAST:event_jBtnNextActionPerformed

    private void jBtnFinishActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnFinishActionPerformed
        this.wizardImpl.finish();
    }//GEN-LAST:event_jBtnFinishActionPerformed

    private void jBtnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnCancelActionPerformed
        this.wizardImpl.cancel();
    }//GEN-LAST:event_jBtnCancelActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBtnBack;
    private javax.swing.JButton jBtnCancel;
    private javax.swing.JButton jBtnFinish;
    private javax.swing.JButton jBtnNext;
    private javax.swing.JPanel jPnlBottom;
    private javax.swing.JPanel jPnlCenter;
    private javax.swing.JPanel jPnlPages;
    private javax.swing.JPanel jPnlSteps;
    // End of variables declaration//GEN-END:variables

    /**
     * @return the jPnlPages
     */
    public javax.swing.JPanel getjPnlPages() {
        return jPnlPages;
    }

    /**
     * @return the jPnlSteps
     */
    public javax.swing.JPanel getjPnlSteps() {
        return jPnlSteps;
    }

    /**
     * @return the jBtnBack
     */
    public javax.swing.JButton getjBtnBack() {
        return jBtnBack;
    }

    /**
     * @return the jBtnCancel
     */
    public javax.swing.JButton getjBtnCancel() {
        return jBtnCancel;
    }

    /**
     * @return the jBtnFinish
     */
    public javax.swing.JButton getjBtnFinish() {
        return jBtnFinish;
    }

    /**
     * @return the jBtnNext
     */
    public javax.swing.JButton getjBtnNext() {
        return jBtnNext;
    }

    public void windowOpened(WindowEvent e) {
    }

    public void windowClosing(WindowEvent e) {
        this.wizardImpl.cancel();
    }

    public void windowClosed(WindowEvent e) {
    }

    public void windowIconified(WindowEvent e) {
    }

    public void windowDeiconified(WindowEvent e) {
    }

    public void windowActivated(WindowEvent e) {
    }

    public void windowDeactivated(WindowEvent e) {
    }
}
